#include "scripteditdialog.h"
#include "ui_scripteditdialog.h"
#include <QDebug>

ScriptEditDialog::ScriptEditDialog(QString text, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ScriptEditDialog)
{
    ui->setupUi(this);
    if (text != 0)
    {
        /*doc = new QTextDocument;
        docLayout = new QPlainTextDocumentLayout(doc);
        doc->setDocumentLayout(docLayout);
        doc->setPlainText(text);*/
        qDebug() << text;
        ui->scriptPlainTextEdit->setPlainText(text);
        //ui->scriptPlainTextEdit->setDocument(doc);
    }
    ui->scriptPlainTextEdit->setFocus();
}

ScriptEditDialog::~ScriptEditDialog()
{
    delete ui;
}

void ScriptEditDialog::on_savePushButton_clicked()
{
    QTextDocument *doc = ui->scriptPlainTextEdit->document();
    emit scriptUpdate(doc->toPlainText());
    accept();
}

void ScriptEditDialog::on_clearPushButton_clicked()
{
    ui->scriptPlainTextEdit->clear();
    ui->scriptPlainTextEdit->setFocus();
}
